package com.delivery.www.service.ServiceImpl;

import com.delivery.www.dao.CouponDao;
import com.delivery.www.dao.DaoImpl.CouponDaoImpl;
import com.delivery.www.po.Coupon;
import com.delivery.www.service.CouponService;
import com.delivery.www.util.JdbcUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class CouponServiceImpl implements CouponService {
    private final CouponDao couponDao;

    public CouponServiceImpl() {
        couponDao = new CouponDaoImpl();
    }

    @Override
    public List<Coupon> getCoupon(int storeId) {
        List<Coupon> coupons = null;
        coupons = couponDao.getCoupon(storeId);
        return coupons;
    }

    @Override
    public boolean addCoupon(int storeId, int value, int min) {
        boolean flag = false;
        int i = couponDao.addCoupon(storeId, value, min);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public boolean deleteCoupon(int couponId) {
        boolean flag = false;
        int i = couponDao.deleteCoupon(couponId);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public Coupon getOneCoupon(int couponId) {
        Coupon coupon = null;
        coupon = couponDao.getOneCoupon(couponId);
        return coupon;
    }
}
